<!--点赞小红心-->
<template>
  <div class="icon-like">
    <img v-if="!isLiked" src="../../../static/images/dangjian/video/icon-like.png" alt="">
    <img v-if="isLiked" src="../../../static/images/dangjian/video/icon-like-press.png" alt="">
  </div>
</template>

<script>
import StorageKeys from '@/common/const/StorageKeys'
export default {
  name: "isLiked",
  props: ["newsId"],
  data() {
    return {
      isLiked: false,
    }
  },
  created () {
    console.log('isLike created')
    this.fetchData()
  },
  activated () {
    console.log('isLike activated')
    this.fetchData()
  },
  methods: {
    fetchData () {
      this.fetchService.contentGetSfdz(this.newsId).then(res => {
         this.isLiked = res.code === 0 && res.data
      })
    }
  },
};
</script>
<style scoped lang="scss">
@import "@/common/stylus/moon.scss";
.icon-like{
  width: pxToRem(24px);
  display: inline-block;
  img{
    width: 100%;
    position: relative;
    top: 3px;
  }
}
</style>
